<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>模仿计算器</title>
    <script type="text/javascript">
        function calc() {
            var num1 = parseFloat(document.getElementById("num1").value);
            var num2 = parseFloat(document.getElementById("num2").value);
            var method = document.getElementById("option").value;
            var result = 0;
            if (method == "+") result = num1 + num2;
            else if (method == "-") result = num1 - num2;
            else if (method == "*") result = num1 * num2;
            else if (method == "/") result = num1 / num2;
            else if (method == "%") result = num1 % num2;
            document.getElementById("result").innerHTML = result;
        }
        function clearnum(){
            document.getElementById("num1").value="";
            document.getElementById("num2").value="";
            document.getElementById("result").innerHTML="";
        }
    </script>
</head>
<body>
<center >
<input id="num1">
<select id="option">
    <option value="+">+</option>
    <option value="-">-</option>
    <option value="*">*</option>
    <option value="/">/</option>
    <option value="%">%</option>
</select>
<input id="num2">=
<span id="result"></span>
<br>
<br>
<input type="button" onclick="calc()" value="开始计算">
<input type="button" onclick="clearnum()" value="清除数据">
</center>
</body>
</html>